package com.lh.dao;

import com.lh.entity.Category;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: LuoHang
 * @Date: 2021/2/11 12:24
 * @Description
 */
@Repository
public class CategoryDao {
    @Autowired
    private SqlSessionTemplate sessionTemplate;

    public List<Category> getCategoryList(Map<String,Object> map){
        return sessionTemplate.selectList("CategoryMapper.getCategoryList",map);
    }

    public int getCount(Map<String,Object> map){
        return sessionTemplate.selectOne("CategoryMapper.getCount",map);
    }

    public int addCategory(Category category){
        return sessionTemplate.insert("CategoryMapper.addCategory",category);
    }

    public int deleteCategoryById(Integer id){
        return sessionTemplate.delete("CategoryMapper.deleteById",id);
    }

    public int updateCategory(Map<String,Object> map){
        return sessionTemplate.update("CategoryMapper.updateCategory",map);
    }

    public Category getCategoryById(Integer id){
        return sessionTemplate.selectOne("CategoryMapper.getCategoryById",id);
    }
}
